package com.zzw.hj83;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 二维数组操作
 * @Author: zzw
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) {
            // 表格的行列值
            int m = in.nextInt();
            int n = in.nextInt();
            if (m > 0 && m <= 9 && n > 0 && n <= 9) {
                System.out.println(0);
            } else {
                System.out.println(-1);
            }
            int[][] arr = new int[m][n];
            // 要交换的两个单元格的行列值
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 < m && y1 < n && x2 < m && y2 < n) {
                int temp = arr[x1][y1];
                arr[x1][y1] = arr[x2][y2];
                arr[x2][y2] = temp;
                System.out.println(0);
            } else {
                System.out.println(-1);
            }
            // 要插入的行的数值
            int ins_row = in.nextInt();
            if (ins_row < m && (m + 1) <= 9) {
                System.out.println(0);
            } else {
                System.out.println(-1);
            }
            // 要插入的行的数值
            int ins_col = in.nextInt();
            if (ins_col < n && (n + 1) <= 9) {
                System.out.println(0);
            } else {
                System.out.println(-1);
            }
            // 要查询的单元格的坐标
            int i = in.nextInt();
            int j = in.nextInt();
            if (i >= 0 && i < m && j >= 0 && j < n) {
                System.out.println(0);
            } else {
                System.out.println(-1);
            }
        }
    }
}